package org.example.mapper;

import org.apache.ibatis.annotations.*;
import org.example.pojo.FoodTag;

import java.util.List;

@Mapper
public interface FoodTagMapper {
    // 修正SQL语法错误，添加food_id列名
    @Select("SELECT * FROM food_tag WHERE food_id = #{foodId}")
    List<FoodTag> findTagsByFoodId(Long foodId);

    @Insert("INSERT INTO food_tag(food_id, tag_name) VALUES(#{foodId}, #{tagName})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void addTag(FoodTag tag);

    // 修正删除方法，按food_id删除
    @Delete("DELETE FROM food_tag WHERE food_id = #{foodId}")
    void deleteByFoodId(Long foodId);
}
